<h1>Listing stocks</h1>

<table>
  <tr>
    <th>Name</th>
    <th>Description</th>
    <th>Face value</th>
    <th>Market value</th>
    <th>Quantity</th>
    <th>Days opening</th>
  </tr>

<% for stock in @stocks %>
  <tr>
    <td><%= link_to stock.name, stock %></td>
    <td><%=h stock.description %></td>
    <td><%=h stock.face_value %></td>
    <td><%=h stock.market_value %></td>
    <td><%=h stock.quantity %></td>
    <td><%=h stock.days_opening %></td>
    
    <td><%= link_to 'Edit', edit_stock_path(stock) %></td>
    <td><%= link_to 'Delete', stock, :confirm => 'Are you sure?', :method => :delete %></td>
    <td><%= if Stock.status(stock) == 1 
		link_to 'Close', 	:action => 'close',
					:id => stock
	    else
		link_to 'Open', 	:action => 'open',
					:id => stock
	    end %></td>
  </tr>
<% end %>
</table>

<br />

<h3><%= link_to 'New stock', new_stock_path %></h3>
